package com.example.chatserver;

import java.util.ArrayList;
import java.util.StringTokenizer;

public class ExtractWorkflow {

	// source
	//          term/tag+term/tag...
	public ExtractWorkflow() {}
	public ExtractWorkflow(String workflowGetResultOfDocument) {
	}
	
	public ArrayList<String> test(String workflowGetResultOfDocument) {
		StringTokenizer seperation = new StringTokenizer(workflowGetResultOfDocument, "\n");
		
		
		String tempStr;
		ArrayList <String> tempList = new ArrayList<String>();
		ArrayList <String> stringList = new ArrayList<String>();
		
		while(true){
			if(!seperation.hasMoreTokens())
				break;
			
			tempStr = seperation.nextToken(); 
			// skip sourceString
			if(!tempStr.matches(".*/.*"))
				continue;
			
			tempList.add(tempStr.trim());
		}
		
		for(int i = 0; i < tempList.size(); i++) {
			// list?
			if(tempList.get(i).matches(".*+.*"))
				tempStr = tempList.get(i).split("\\+")[0];
			else
				tempStr = tempList.get(i);
			
			// only noun
			String[] tempSplit = tempStr.split("/");
			if(tempSplit[1].startsWith("n")) {
				stringList.add(tempSplit[0]);
			}
		}
		
		return stringList;
	}
}
